home *** CD-ROM | disk | FTP | other *** search
- package com.ibm.uvm.abt.edit;
-
- import java.awt.Point;
- import java.beans.PropertyEditorSupport;
- import java.util.ResourceBundle;
-
- public class PointPropertyEditor extends PropertyEditorSupport {
- private static ResourceBundle resabtedit = ResourceBundle.getBundle("com/ibm/uvm/abt/edit/abtedit");
-
- public String getAsText() {
- return ((PropertyEditorSupport)this).getValue() instanceof String ? (String)((PropertyEditorSupport)this).getValue() : ((Point)((PropertyEditorSupport)this).getValue()).x + ", " + ((Point)((PropertyEditorSupport)this).getValue()).y;
- }
-
- public String getJavaInitializationString() {
- Point value = (Point)((PropertyEditorSupport)this).getValue();
- return value == null ? "new java.awt.Point(0,0)" : "new java.awt.Point(" + value.x + ", " + value.y + ")";
- }
-
- private Point parseForPoint(String text) throws Exception, NumberFormatException {
- int x = text.indexOf(",");
- if (x < 0) {
- throw new Exception(resabtedit.getString("x_and_y_must_be_sep"));
- } else {
- String yText = text.substring(x + ",".length());
- String xText = text.substring(0, x);
- return new Point(Integer.valueOf(xText.trim()), Integer.valueOf(yText.trim()));
- }
- }
- }
-